﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using SMO.Models;

namespace SMO.Models.SimplObject
{
    public class BankRepository
    {
        private SMO_LinQDataContext datacontent = new SMO_LinQDataContext();
        public IQueryable<Bank> GetAll()
        {
            return datacontent.Banks;
        }

        public Bank GetByBankID(string id)
        {
            return datacontent.Banks.SingleOrDefault(s => s.BankId.ToString().Trim() == id.Trim());
        }

        public Bank GetFirst()
        {
            return datacontent.Banks.FirstOrDefault();
        }

        public void Add(Bank bank)
        {
            datacontent.Banks.InsertOnSubmit(bank);
        }

        public void Delete(Bank bank)
        {
            datacontent.Banks.DeleteOnSubmit(bank);
        }

        public void Save()
        {
            datacontent.SubmitChanges();
        } 
    }
}
